home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kdiroperator.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-01-15  |  28.6 KB  |  951 lines

  1. // -*- c++ -*-
  2. /* This file is part of the KDE libraries
  3.     Copyright (C) 1999 Stephan Kulow <coolo@kde.org>
  4.           2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.  
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.     Boston, MA 02110-1301, USA.
  20. */
  21. #ifndef KDIROPERATOR_H_
  22. #define KDIROPERATOR_H_
  23.  
  24. #include <qwidget.h>
  25. #include <qptrstack.h>
  26.  
  27. #include <kaction.h>
  28. #include <kcompletion.h>
  29. #include <kdirlister.h>
  30. #include <kfileview.h>
  31. #include <kfileitem.h>
  32. #include <kfile.h>
  33.  
  34. class QPopupMenu;
  35. class QTimer;
  36.  
  37. class KAction;
  38. class KDirLister;
  39. class KToggleAction;
  40. class KActionSeparator;
  41. class KActionMenu;
  42. class QWidgetStack;
  43. class KProgress;
  44. namespace KIO {
  45.   class CopyJob;
  46.   class DeleteJob;
  47. }
  48.  
  49. /**
  50.  * This widget works as a network transparent filebrowser. You specify a URL
  51.  * to display and this url will be loaded via KDirLister. The user can
  52.  * browse through directories, highlight and select files, delete or rename
  53.  * files.
  54.  *
  55.  * It supports different views, e.g. a detailed view (see KFileDetailView),
  56.  * a simple icon view (see KFileIconView), a combination of two views,
  57.  * separating directories and files ( KCombiView).
  58.  *
  59.  * Additionally, a preview view is available (see KFilePreview), which can
  60.  * show either a simple or detailed view and additionally a preview widget
  61.  * (see setPreviewWidget()). KImageFilePreview is one implementation
  62.  * of a preview widget, that displays previews for all supported filetypes
  63.  * utilizing KIO::PreviewJob.
  64.  *
  65.  * Currently, those classes don't support Drag&Drop out of the box -- there
  66.  * you have to use your own view-classes. You can use some DnD-aware views
  67.  * from Bj∩┐╜n Sahlstr∩┐╜ <bjorn@kbear.org> until they will be integrated
  68.  * into this library. See http://devel-home.kde.org/~pfeiffer/DnD-classes.tar.gz
  69.  *
  70.  * This widget is the one used in the KFileDialog.
  71.  *
  72.  * Basic usage is like this:
  73.  * \code
  74.  *   KDirOperator *op = new KDirOperator( KURL( "file:/home/gis" ), this );
  75.  *   // some signals you might be interested in
  76.  *   connect(op, SIGNAL(urlEntered(const KURL&)),
  77.  *           SLOT(urlEntered(const KURL&)));
  78.  *   connect(op, SIGNAL(fileHighlighted(const KFileItem *)),
  79.  *           SLOT(fileHighlighted(const KFileItem *)));
  80.  *   connect(op, SIGNAL(fileSelected(const KFileItem *)),
  81.  *           SLOT(fileSelected(const KFileItem *)));
  82.  *   connect(op, SIGNAL(finishedLoading()),
  83.  *           SLOT(slotLoadingFinished()));
  84.  *
  85.  *   op->readConfig( KGlobal::config(), "Your KDiroperator ConfigGroup" );
  86.  *   op->setView(KFile::Default);
  87.  * \endcode
  88.  *
  89.  * This will create a childwidget of 'this' showing the directory contents
  90.  * of /home/gis in the default-view. The view is determined by the readConfig()
  91.  * call, which will read the KDirOperator settings, the user left your program
  92.  * with (and which you saved with op->writeConfig()).
  93.  *
  94.  * @short A widget for displaying files and browsing directories.
  95.  * @author Stephan Kulow <coolo@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org>
  96.  */
  97. class KIO_EXPORT KDirOperator : public QWidget
  98. {
  99.     Q_OBJECT
  100.  
  101.  public:
  102.     /**
  103.      * The various action types. These values can be or'd together
  104.      * @since 3.1
  105.      */
  106.     enum ActionTypes { SortActions = 1,
  107.                        ViewActions = 2,
  108.                        NavActions = 4,
  109.                        FileActions = 8,
  110.                        AllActions = 15 };
  111.     /**
  112.      * Constructs the KDirOperator with no initial view. As the views are
  113.      * configurable, call readConfig() to load the user's configuration
  114.      * and then setView to explicitly set a view.
  115.      *
  116.      * This constructor doesn't start loading the url, setView will do it.
  117.      */
  118.     KDirOperator(const KURL& urlName = KURL(),
  119.          QWidget *parent = 0, const char* name = 0);
  120.     /**
  121.      * Destroys the KDirOperator.
  122.      */
  123.     virtual ~KDirOperator();
  124.  
  125.     /**
  126.      * Enables/disables showing hidden files.
  127.      */
  128.     // ### KDE4: make virtual
  129.     void setShowHiddenFiles ( bool s ) { showHiddenAction->setChecked( s ); }
  130.  
  131.     /**
  132.      * @returns true when hidden files are shown or false otherwise.
  133.      */
  134.     bool showHiddenFiles () const { return showHiddenAction->isChecked(); }
  135.  
  136.     /**
  137.      * Stops loading immediately. You don't need to call this, usually.
  138.      */
  139.     void close();
  140.     /// Reimplemented to avoid "hidden virtual" warnings
  141.     virtual bool close( bool alsoDelete ) { return QWidget::close( alsoDelete ); }
  142.  
  143.     /**
  144.      * Sets a filter like "*.cpp *.h *.o". Only files matching that filter
  145.      * will be shown. Call updateDir() to apply it.
  146.      *
  147.      * @see KDirLister::setNameFilter
  148.      * @see nameFilter
  149.      */
  150.     void setNameFilter(const QString& filter);
  151.  
  152.     /**
  153.      * @returns the current namefilter.
  154.      * @see setNameFilter
  155.      */
  156.     const QString& nameFilter() const { return dir->nameFilter(); }
  157.  
  158.     /**
  159.      * Sets a list of mimetypes as filter. Only files of those mimetypes
  160.      * will be shown.
  161.      *
  162.      * Example:
  163.      * \code
  164.      * QStringList filter;
  165.      * filter << "text/html" << "image/png" << "inode/directory";
  166.      * dirOperator->setMimefilter( filter );
  167.      * \endcode
  168.      *
  169.      * Node: Without the mimetype inode/directory, only files would be shown.
  170.      * Call updateDir() to apply it.
  171.      *
  172.      * @see KDirLister::setMimeFilter
  173.      * @see mimeFilter
  174.      */
  175.     void setMimeFilter( const QStringList& mimetypes );
  176.  
  177.     /**
  178.      * @returns the current mime filter.
  179.      */
  180.     QStringList mimeFilter() const { return dir->mimeFilters(); }
  181.  
  182.     /**
  183.      * Clears both the namefilter and mimetype filter, so that all files and
  184.      * directories will be shown. Call updateDir() to apply it.
  185.      *
  186.      * @see setMimeFilter
  187.      * @see setNameFilter
  188.      */
  189.     void clearFilter();
  190.  
  191.     /**
  192.      * @returns the current url
  193.      */
  194.     KURL url() const;
  195.  
  196.     /**
  197.      * Sets a new url to list.
  198.      * @param clearforward specifies whether the "forward" history should be cleared.
  199.      * @param url the URL to set
  200.      */
  201.     // ### KDE4: make virtual
  202.     void setURL(const KURL& url, bool clearforward);
  203.  
  204.     /**
  205.      * Clears the current selection and attempts to set @p filename
  206.      * the current file. filename is just the name, no path or url.
  207.      */
  208.     void setCurrentItem( const QString& filename );
  209.  
  210.     /**
  211.      * Sets a new KFileView to be used for showing and browsing files.
  212.      * Note: this will read the current url() to fill the view.
  213.      *
  214.      * @see KFileView
  215.      * @see KFileIconView
  216.      * @see KFileDetailView
  217.      * @see KCombiView
  218.      * @see view
  219.      */
  220.     // ### KDE4: make virtual
  221.     void setView(KFileView *view);
  222.  
  223.     /**
  224.      * @returns the currently used view.
  225.      * @see setView
  226.      */
  227.     KFileView * view() const { return m_fileView; }
  228.  
  229.     /**
  230.      * Returns the widget of the current view. 0L if there is no view/widget.
  231.      * (KFileView itself is not a widget.)
  232.      */
  233.     QWidget * viewWidget() const { return m_fileView ? m_fileView->widget() : 0L; }
  234.  
  235.     /**
  236.      * Sets one of the predefined fileviews
  237.      * @see KFile::FileView
  238.      */
  239.     // ### KDE4: make virtual
  240.     void setView(KFile::FileView view);
  241.  
  242.     /**
  243.      * Sets the way to sort files and directories.
  244.      */
  245.     void setSorting( QDir::SortSpec );
  246.  
  247.     /**
  248.      * @returns the current way of sorting files and directories
  249.      */
  250.     QDir::SortSpec sorting() const { return mySorting; }
  251.  
  252.     /**
  253.      * @returns true if we are displaying the root directory of the current url
  254.      */
  255.     bool isRoot() const { return url().path() == QChar('/'); }
  256.  
  257.     /**
  258.      * @returns the object listing the directory
  259.      */
  260.     KDirLister *dirLister() const { return dir; }
  261.  
  262.     /**
  263.      * @returns the progress widget, that is shown during directory listing.
  264.      * You can for example reparent() it to put it into a statusbar.
  265.      */
  266.     KProgress * progressBar() const;
  267.  
  268.     /**
  269.      * Sets the listing/selection mode for the views, an OR'ed combination of
  270.      * @li File
  271.      * @li Directory
  272.      * @li Files
  273.      * @li ExistingOnly
  274.      * @li LocalOnly
  275.      *
  276.      * You cannot mix File and Files of course, as the former means
  277.      * single-selection mode, the latter multi-selection.
  278.      */
  279.     // ### KDE4: make virtual
  280.     void setMode( KFile::Mode m );
  281.     /**
  282.      * @returns the listing/selection mode.
  283.      */
  284.     KFile::Mode mode() const;
  285.  
  286.     /**
  287.      * Sets a preview-widget to be shown next to the file-view.
  288.      * The ownership of @p w is transferred to KDirOperator, so don't
  289.      * delete it yourself!
  290.      */
  291.     // ### KDE4: make virtual
  292.     void setPreviewWidget(const QWidget *w);
  293.  
  294.     /**
  295.      * @returns a list of all currently selected items. If there is no view,
  296.      * then 0L is returned.
  297.      */
  298.     const KFileItemList * selectedItems() const {
  299.     return ( m_fileView ? m_fileView->selectedItems() : 0L );
  300.     }
  301.  
  302.     /**
  303.      * @returns true if @p item is currently selected, or false otherwise.
  304.      */
  305.     inline bool isSelected( const KFileItem *item ) const {
  306.     return ( m_fileView ? m_fileView->isSelected( item ) : false );
  307.     }
  308.  
  309.     /**
  310.      * @returns the number of directories in the currently listed url.
  311.      * Returns 0 if there is no view.
  312.      */
  313.     int numDirs() const;
  314.  
  315.     /**
  316.      * @returns the number of files in the currently listed url.
  317.      * Returns 0 if there is no view.
  318.      */
  319.     int numFiles() const;
  320.  
  321.     /**
  322.      * @returns a KCompletion object, containing all filenames and
  323.      * directories of the current directory/URL.
  324.      * You can use it to insert it into a KLineEdit or KComboBox
  325.      * Note: it will only contain files, after prepareCompletionObjects()
  326.      * has been called. It will be implicitly called from makeCompletion()
  327.      * or makeDirCompletion()
  328.      */
  329.     KCompletion * completionObject() const {
  330.     return const_cast<KCompletion *>( &myCompletion );
  331.     }
  332.  
  333.     /**
  334.      * @returns a KCompletion object, containing only all directories of the
  335.      * current directory/URL.
  336.      * You can use it to insert it into a KLineEdit or KComboBox
  337.      * Note: it will only contain directories, after
  338.      * prepareCompletionObjects() has been called. It will be implicitly
  339.      * called from makeCompletion() or makeDirCompletion()
  340.      */
  341.     KCompletion *dirCompletionObject() const {
  342.     return const_cast<KCompletion *>( &myDirCompletion );
  343.     }
  344.  
  345.     /**
  346.      * an accessor to a collection of all available Actions. The actions
  347.      * are static, they will be there all the time (no need to connect to
  348.      * the signals KActionCollection::inserted() or removed().
  349.      *
  350.      * There are the following actions:
  351.      *
  352.      * @li popupMenu : an ActionMenu presenting a popupmenu with all actions
  353.      * @li up : changes to the parent directory
  354.      * @li back : goes back to the previous directory
  355.      * @li forward : goes forward in the history
  356.      * @li home : changes to the user's home directory
  357.      * @li reload : reloads the current directory
  358.      * @li separator : a separator
  359.      * @li mkdir : opens a dialog box to create a directory
  360.      * @li delete : deletes the selected files/directories
  361.      * @li sorting menu : an ActionMenu containing all sort-options
  362.      * @li by name : sorts by name
  363.      * @li by date : sorts by date
  364.      * @li by size : sorts by size
  365.      * @li reversed : reverses the sort order
  366.      * @li dirs first : sorts directories before files
  367.      * @li case insensitive : sorts case insensitively
  368.      * @li view menu : an ActionMenu containing all actions concerning the view
  369.      * @li short view : shows a simple fileview
  370.      * @li detailed view : shows a detailed fileview (dates, permissions ,...)
  371.      * @li show hidden : shows hidden files
  372.      * @li separate dirs : shows directories in a separate pane
  373.      * @li preview  : shows a preview next to the fileview
  374.      * @li single : hides the separate view for directories or the preview
  375.      * @li properties : shows a KPropertiesDialog for the selected files
  376.      *
  377.      * The short and detailed view are in an exclusive group. The sort-by
  378.      * actions are in an exclusive group as well. Also the "separate dirs",
  379.      * "preview" and "single" actions are in an exclusive group.
  380.      *
  381.      * You can e.g. use
  382.      * \code
  383.      * actionCollection()->action( "up" )->plug( someToolBar );
  384.      * \endcode
  385.      * to add a button into a toolbar, which makes the dirOperator change to
  386.      * its parent directory.
  387.      *
  388.      * @returns all available Actions
  389.      */
  390.     KActionCollection * actionCollection() const { return myActionCollection; }
  391.  
  392.     /**
  393.      * Sets the config object and the to be used group in KDirOperator. This
  394.      * will be used to store the view's configuration via
  395.      * KFileView::writeConfig() (and for KFileView::readConfig()).
  396.      * If you don't set this, the views cannot save and restore their
  397.      * configuration.
  398.      *
  399.      * Usually you call this right after KDirOperator creation so that the view
  400.      * instantiation can make use of it already.
  401.      *
  402.      * Note that KDirOperator does NOT take ownership of that object (typically
  403.      * it's KGlobal::config() anyway.
  404.      *
  405.      * @see viewConfig
  406.      * @see viewConfigGroup
  407.      * @since 3.1
  408.      */
  409.     // ### KDE4: make virtual
  410.     void setViewConfig( KConfig *config, const QString& group );
  411.  
  412.     /**
  413.      * Returns the KConfig object used for saving and restoring view's
  414.      * configuration.
  415.      * @returns the KConfig object used for saving and restoring view's
  416.      * configuration.
  417.      * @since 3.1
  418.      */
  419.     KConfig *viewConfig();
  420.  
  421.     /**
  422.      * Returns the group name used for saving and restoring view's
  423.      * configuration.
  424.      * @returns the group name used for saving and restoring view's
  425.      * configuration.
  426.      * @since 3.1
  427.      */
  428.     QString viewConfigGroup() const;
  429.  
  430.     /**
  431.      * Reads the default settings for a view, i.e. the default KFile::FileView.
  432.      * Also reads the sorting and whether hidden files should be shown.
  433.      * Note: the default view will not be set - you have to call
  434.      * \code
  435.      * setView( KFile::Default )
  436.      * \endcode
  437.      * to apply it.
  438.      *
  439.      * @see setView
  440.      * @see setViewConfig
  441.      * @see writeConfig
  442.      */
  443.     virtual void readConfig( KConfig *, const QString& group = QString::null );
  444.  
  445.     /**
  446.      * Saves the current settings like sorting, simple or detailed view.
  447.      *
  448.      * @see readConfig
  449.      * @see setViewConfig
  450.      */
  451.     virtual void writeConfig( KConfig *, const QString& group = QString::null );
  452.  
  453.  
  454.     /**
  455.      * This is a KFileDialog specific hack: we want to select directories with
  456.      * single click, but not files. But as a generic class, we have to be able
  457.      * to select files on single click as well.
  458.      *
  459.      * This gives us the opportunity to do both.
  460.      *
  461.      * The default is false, set it to true if you don't want files selected
  462.      * with single click.
  463.      */
  464.     void setOnlyDoubleClickSelectsFiles( bool enable );
  465.  
  466.     /**
  467.      * @returns whether files (not directories) should only be select()ed by
  468.      * double-clicks.
  469.      * @see setOnlyDoubleClickSelectsFiles
  470.      */
  471.     bool onlyDoubleClickSelectsFiles() const;
  472.  
  473.     /**
  474.      * Creates the given directory/url. If it is a relative path,
  475.      * it will be completed with the current directory.
  476.      * If enterDirectory is true, the directory will be entered after a
  477.      * successful operation. If unsuccessful, a messagebox will be presented
  478.      * to the user.
  479.      * @returns true if the directory could be created.
  480.      */
  481.     // ### KDE4: make virtual and turn QString into KURL
  482.     bool mkdir( const QString& directory, bool enterDirectory = true );
  483.  
  484.     /**
  485.      * Starts and returns a KIO::DeleteJob to delete the given @p items.
  486.      *
  487.      * @param items the list of items to be deleted
  488.      * @param ask specifies whether a confirmation dialog should be shown
  489.      * @param showProgress passed to the DeleteJob to show a progress dialog
  490.      */
  491.     // ### KDE4: make virtual
  492.     KIO::DeleteJob * del( const KFileItemList& items,
  493.                           bool ask = true, bool showProgress = true );
  494.  
  495.     /**
  496.      * Starts and returns a KIO::DeleteJob to delete the given @p items.
  497.      *
  498.      * @param items the list of items to be deleted
  499.      * @param parent the parent widget used for the confirmation dialog
  500.      * @param ask specifies whether a confirmation dialog should be shown
  501.      * @param showProgress passed to the DeleteJob to show a progress dialog
  502.      * @since 3.1
  503.      */
  504.     // ### KDE4: make virtual
  505.     KIO::DeleteJob * del( const KFileItemList& items, QWidget *parent,
  506.                           bool ask = true, bool showProgress = true );
  507.  
  508.     /**
  509.      * Clears the forward and backward history.
  510.      */
  511.     void clearHistory();
  512.  
  513.     /**
  514.      * When going up in the directory hierarchy, KDirOperator can highlight
  515.      * the directory that was just left.
  516.      *
  517.      * I.e. when you go from /home/gis/src to /home/gis, the item "src" will
  518.      * be made the current item.
  519.      *
  520.      * Default is off, because this behavior introduces bug #136630.
  521.      * Don't enable until this bug is fixed.
  522.      */
  523.     // ### KDE4: make virtual
  524.     void setEnableDirHighlighting( bool enable );
  525.  
  526.     /**
  527.      * @returns whether the last directory will be made the current item
  528.      * when going up in the directory hierarchy.
  529.      *
  530.      * Default is false.
  531.      */
  532.     bool dirHighlighting() const;
  533.  
  534.     /**
  535.      * @returns true if we are in directory-only mode, that is, no files are
  536.      * shown.
  537.      */
  538.     bool dirOnlyMode() const { return dirOnlyMode( myMode ); }
  539.  
  540.     static bool dirOnlyMode( uint mode ) {
  541.         return ( (mode & KFile::Directory) &&
  542.                  (mode & (KFile::File | KFile::Files)) == 0 );
  543.     }
  544.  
  545.     /**
  546.      * Sets up the action menu.
  547.      * @param whichActions is an value of OR'd ActionTypes that controls which actions to show in the action menu
  548.      */
  549.     void setupMenu(int whichActions);
  550.  
  551.     /**
  552.      * Reimplemented - allow dropping of files if @p b is true
  553.      * @param b true if the widget should allow dropping of files
  554.      */
  555.     virtual void setAcceptDrops(bool b);
  556.  
  557.     /**
  558.      * Sets the options for dropping files.
  559.      * @see KFileView::DropOptions
  560.      * @since 3.2
  561.      */
  562.      // ### KDE4: make virtual
  563.     void setDropOptions(int options);
  564.  
  565.     /**
  566.      * Starts and returns a KIO::CopyJob to trash the given @p items.
  567.      *
  568.      * @param items the list of items to be trashed
  569.      * @param parent the parent widget used for the confirmation dialog
  570.      * @param ask specifies whether a confirmation dialog should be shown
  571.      * @param showProgress passed to the CopyJob to show a progress dialog
  572.      * @since 3.4
  573.      */
  574.      // ### KDE4: make virtual
  575.     KIO::CopyJob * trash( const KFileItemList& items, QWidget *parent,
  576.                        bool ask = true, bool showProgress = true );
  577.  
  578. protected:
  579.     /**
  580.      * A view factory for creating predefined fileviews. Called internally by setView
  581.      * , but you can also call it directly. Reimplement this if you depend on self defined fileviews.
  582.      * @param parent is the QWidget to be set as parent
  583.      * @param view is the predefined view to be set, note: this can be several ones OR:ed together.
  584.      * @returns the created KFileView
  585.      * @see KFileView
  586.      * @see KCombiView
  587.      * @see KFileDetailView
  588.      * @see KFileIconView
  589.      * @see KFilePreview
  590.      * @see KFile::FileView
  591.      * @see setView
  592.      */
  593.      virtual KFileView* createView( QWidget* parent, KFile::FileView view );
  594.      /**
  595.      * Sets a custom KDirLister to list directories.
  596.      */
  597.     // ### KDE4: make virtual
  598.     void setDirLister( KDirLister *lister );
  599.  
  600.     virtual void resizeEvent( QResizeEvent * );
  601.  
  602.     /**
  603.      * Sets up all the actions. Called from the constructor, you usually
  604.      * better not call this.
  605.      */
  606.     void setupActions();
  607.  
  608.     /**
  609.      * Updates the sorting-related actions to comply with the current sorting
  610.      * @see sorting
  611.      */
  612.     void updateSortActions();
  613.  
  614.     /**
  615.      * Updates the view-related actions to comply with the current
  616.      * KFile::FileView
  617.      */
  618.     void updateViewActions();
  619.  
  620.     /**
  621.      * Sets up the context-menu with all the necessary actions. Called from the
  622.      * constructor, you usually don't need to call this.
  623.      * @since 3.1
  624.      */
  625.     void setupMenu();
  626.  
  627.     /**
  628.      * Synchronizes the completion objects with the entries of the
  629.      * currently listed url.
  630.      *
  631.      * Automatically called from makeCompletion() and
  632.      * makeDirCompletion()
  633.      */
  634.     void prepareCompletionObjects();
  635.  
  636.     /**
  637.      * Checks if there support from KIO::PreviewJob for the currently
  638.      * shown files, taking mimeFilter() and nameFilter() into account
  639.      * Enables/disables the preview-action accordingly.
  640.      */
  641.     bool checkPreviewSupport();
  642.  
  643. public slots:
  644.     /**
  645.      * Goes one step back in the history and opens that url.
  646.      */
  647.     // ### KDE4: make virtual
  648.     void back();
  649.  
  650.     /**
  651.      * Goes one step forward in the history and opens that url.
  652.      */
  653.     // ### KDE4: make virtual
  654.     void forward();
  655.  
  656.     /**
  657.      * Enters the home directory.
  658.      */
  659.     // ### KDE4: make virtual
  660.     void home();
  661.  
  662.     /**
  663.      * Goes one directory up from the current url.
  664.      */
  665.     // ### KDE4: make virtual
  666.     void cdUp();
  667.  
  668.     /**
  669.      * to update the view after changing the settings
  670.      */
  671.     void updateDir();
  672.  
  673.     /**
  674.      * Re-reads the current url.
  675.      */
  676.     // ### KDE4: make virtual
  677.     void rereadDir();
  678.  
  679.     /**
  680.      * Opens a dialog to create a new directory.
  681.      */
  682.     // ### KDE4: make virtual
  683.     void mkdir();
  684.  
  685.     /**
  686.      * Deletes the currently selected files/directories.
  687.      */
  688.     // ### KDE4: make virtual
  689.     void deleteSelected();
  690.  
  691.     /**
  692.      * Enables/disables actions that are selection dependent. Call this e.g.
  693.      * when you are about to show a popup menu using some of KDirOperators
  694.      * actions.
  695.      */
  696.     void updateSelectionDependentActions();
  697.  
  698.     /**
  699.      * Tries to complete the given string (only completes files).
  700.      */
  701.     QString makeCompletion(const QString&);
  702.  
  703.     /**
  704.      * Tries to complete the given string (only completes directores).
  705.      */
  706.     QString makeDirCompletion(const QString&);
  707.  
  708.     /**
  709.      * Trashes the currently selected files/directories.
  710.      * @since 3.4
  711.      */
  712.     // ### KDE4: make virtual
  713.     void trashSelected(KAction::ActivationReason, Qt::ButtonState);
  714.  
  715. protected slots:
  716.     /**
  717.      * Restores the normal cursor after showing the busy-cursor. Also hides
  718.      * the progressbar.
  719.      */
  720.     void resetCursor();
  721.  
  722.     /**
  723.      * Called after setURL() to load the directory, update the history,
  724.      * etc.
  725.      */
  726.     void pathChanged();
  727.  
  728.     /**
  729.      * Adds a new list of KFileItems to the view
  730.      * (coming from KDirLister)
  731.      */
  732.     void insertNewFiles(const KFileItemList &newone);
  733.  
  734.     /**
  735.      * Removes the given KFileItem item from the view (usually called from
  736.      * KDirLister).
  737.      */
  738.     void itemDeleted(KFileItem *);
  739.  
  740.     /**
  741.      * Enters the directory specified by the given @p item.
  742.      */
  743.     // ### KDE4: make virtual
  744.     void selectDir(const KFileItem *item );
  745.  
  746.     /**
  747.      * Emits fileSelected( item )
  748.      */
  749.     void selectFile(const KFileItem *item);
  750.  
  751.     /**
  752.      * Emits fileHighlighted( i )
  753.      */
  754.     void highlightFile(const KFileItem* i) { emit fileHighlighted( i ); }
  755.  
  756.     /**
  757.      * Called upon right-click to activate the popupmenu.
  758.      */
  759.     virtual void activatedMenu( const KFileItem *, const QPoint& pos );
  760.  
  761.     /**
  762.      * Changes sorting to sort by name
  763.      */
  764.     void sortByName()         { byNameAction->setChecked( true ); }
  765.  
  766.     /**
  767.      * Changes sorting to sort by size
  768.      */
  769.     void sortBySize()         { bySizeAction->setChecked( true ); }
  770.  
  771.     /**
  772.      * Changes sorting to sort by date
  773.      */
  774.     void sortByDate()         { byDateAction->setChecked( true ); }
  775.  
  776.     /**
  777.      * Changes sorting to reverse sorting
  778.      */
  779.     void sortReversed()     { reverseAction->setChecked( !reverseAction->isChecked() ); }
  780.  
  781.     /**
  782.      * Toggles showing directories first / having them sorted like files.
  783.      */
  784.     void toggleDirsFirst()     { dirsFirstAction->setChecked( !dirsFirstAction->isChecked() ); }
  785.  
  786.     /**
  787.      * Toggles case sensitive / case insensitive sorting
  788.      */
  789.     void toggleIgnoreCase()     { caseInsensitiveAction->setChecked( !caseInsensitiveAction->isChecked() ); }
  790.  
  791.     /**
  792.      * Tries to make the given @p match as current item in the view and emits
  793.      * completion( match )
  794.      */
  795.     void slotCompletionMatch(const QString& match);
  796.  
  797. signals:
  798.     void urlEntered(const KURL& );
  799.     void updateInformation(int files, int dirs);
  800.     void completion(const QString&);
  801.     void finishedLoading();
  802.  
  803.     /**
  804.      * Emitted whenever the current fileview is changed, either by an explicit
  805.      * call to setView() or by the user selecting a different view thru
  806.      * the GUI.
  807.      */
  808.     void viewChanged( KFileView * newView );
  809.  
  810.     /**
  811.      * Emitted when a file is highlighted or generally the selection changes in
  812.      * multiselection mode. In the latter case, @p item is 0L. You can access
  813.      * the selected items with selectedItems().
  814.      */
  815.     void fileHighlighted( const KFileItem *item );
  816.     void dirActivated( const KFileItem *item );
  817.     void fileSelected( const KFileItem *item );
  818.     /**
  819.      * Emitted when files are dropped. Dropping files is disabled by
  820.      * default. You need to enable it with setAcceptDrops()
  821.      * @param item the item on which the drop occurred or 0.
  822.      * @param event the drop event itself.
  823.      * @param urls the urls that where dropped.
  824.      * @since 3.2
  825.      */
  826.     void dropped(const KFileItem *item, QDropEvent*event, const KURL::List&urls);
  827. private:
  828.     /**
  829.      * Contains all URLs you can reach with the back button.
  830.      */
  831.     QPtrStack<KURL> backStack;
  832.  
  833.     /**
  834.      * Contains all URLs you can reach with the forward button.
  835.      */
  836.     QPtrStack<KURL> forwardStack;
  837.  
  838.     KDirLister *dir;
  839.     KURL currUrl;
  840.  
  841.     KCompletion myCompletion;
  842.     KCompletion myDirCompletion;
  843.     bool myCompleteListDirty;
  844.     QDir::SortSpec mySorting;
  845.  
  846.     /**
  847.      * Checks whether we preview support is available for the current
  848.      * mimetype/namefilter
  849.      */
  850.     bool checkPreviewInternal() const;
  851.  
  852.     /**
  853.       * takes action on the new location. If it's a directory, change
  854.       * into it, if it's a file, correct the name, etc.
  855.       */
  856.     void checkPath(const QString& txt, bool takeFiles = false);
  857.  
  858.     void connectView(KFileView *);
  859.  
  860.     bool openURL( const KURL& url, bool keep = false, bool reload = false );
  861.  
  862.     KFileView *m_fileView;
  863.     KFileItemList pendingMimeTypes;
  864.  
  865.     // the enum KFile::FileView as an int
  866.     int m_viewKind;
  867.     int defaultView;
  868.  
  869.     KFile::Mode myMode;
  870.     KProgress *progress;
  871.  
  872.     const QWidget *myPreview;    // temporary pointer for the preview widget
  873.  
  874.     // actions for the popupmenus
  875.     // ### clean up all those -- we have them all in the actionMenu!
  876.     KActionMenu *actionMenu;
  877.  
  878.     KAction     *backAction;
  879.     KAction     *forwardAction;
  880.     KAction     *homeAction;
  881.     KAction     *upAction;
  882.     KAction     *reloadAction;
  883.     KActionSeparator *actionSeparator;
  884.     KAction     *mkdirAction;
  885.  
  886.     KActionMenu *sortActionMenu;
  887.     KRadioAction *byNameAction;
  888.     KRadioAction *byDateAction;
  889.     KRadioAction *bySizeAction;
  890.     KToggleAction *reverseAction;
  891.     KToggleAction *dirsFirstAction;
  892.     KToggleAction *caseInsensitiveAction;
  893.  
  894.     KActionMenu *viewActionMenu;
  895.     KRadioAction *shortAction;
  896.     KRadioAction *detailedAction;
  897.     KToggleAction *showHiddenAction;
  898.     KToggleAction *separateDirsAction;
  899.  
  900.     KActionCollection *myActionCollection;
  901.     KActionCollection *viewActionCollection;
  902.  
  903. private slots:
  904.     /**
  905.      * @internal
  906.      */
  907.     void slotDetailedView();
  908.     void slotSimpleView();
  909.     void slotToggleHidden( bool );
  910.  
  911.     void slotSeparateDirs();
  912.     void slotDefaultPreview();
  913.     void togglePreview( bool );
  914.  
  915.     void slotSortByName();
  916.     void slotSortBySize();
  917.     void slotSortByDate();
  918.     void slotSortReversed();
  919.     void slotToggleDirsFirst();
  920.     void slotToggleIgnoreCase();
  921.  
  922.     void slotStarted();
  923.     void slotProgress( int );
  924.     void slotShowProgress();
  925.     void slotIOFinished();
  926.     void slotCanceled();
  927.     void slotRedirected( const KURL& );
  928.  
  929.     void slotViewActionAdded( KAction * );
  930.     void slotViewActionRemoved( KAction * );
  931.     void slotViewSortingChanged( QDir::SortSpec );
  932.  
  933.     void slotClearView();
  934.     void slotRefreshItems( const KFileItemList& items );
  935.  
  936.     void slotProperties();
  937.  
  938.     void insertViewDependentActions();
  939.  
  940. private:
  941.     static bool isReadable( const KURL& url );
  942.  
  943. protected:
  944.     virtual void virtual_hook( int id, void* data );
  945. private:
  946.     class KDirOperatorPrivate;
  947.     KDirOperatorPrivate *d;
  948. };
  949.  
  950. #endif
  951.